package com.bzoa.api.service.imp;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bzoa.api.dto.MenuDTO;
import com.bzoa.api.entity.Menu;
import com.bzoa.api.mapper.MenuMapper;
import com.bzoa.api.service.MenuService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author lands
 * @Date 2023/3/20 10:44
 * @Description TODO
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {

    @Override
    public List<MenuDTO> listProduct() {
        List<MenuDTO> menuDTOS = this.baseMapper.listProduct();
        for (MenuDTO menuDTO : menuDTOS){
            menuDTO.setChildren(this.baseMapper.listProductById(menuDTO.getMenuId()+""));
        }
        if(menuDTOS!=null){
            return menuDTOS;
        }else {
            return  null;
        }

    }
}